package cn.chencq.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import cn.chencq.exception.MyException;

/**
 * Redis切面处理类
 * 
 * @author chencq
 * @email chenchaoqun@incar100.com
 */
@Aspect
@Configuration
public class RedisAspect {
	// 是否开启redis缓存 true开启 false关闭
	@Value("${spring.redis.open: #{false}}")
	private boolean open;

	@Around("execution(* cn.chencq.utils.redis.RedisUtils.*(..))")
	public Object around(ProceedingJoinPoint point) throws Throwable {
		Object result = null;
		if (open) {
			try {
				result = point.proceed();
			} catch (Exception e) {
				throw new MyException("Redis服务异常");
			}
		}
		return result;
	}
}
